#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "QTime"
#include "QTimer"

int flag = 0;

mainwindow::mainwindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::mainwindow)
{
    ui->setupUi(this);
    ui->label_2->hide();
    ui->pushButton_2->hide();
    this->setWindowIcon(QIcon(":/image/menu.jpeg"));
    QMovie *mov1 = new QMovie(":/image/77.gif");
    QSize siz;
    siz=ui->label_3->size();
    mov1->setScaledSize(siz);
    ui->label_3->setMovie(mov1);
    mov1->start();

   // QSound::play(":/image/canon.wav");

    ui->menuBar->hide();
    ui->statusBar->hide();
    ui->mainToolBar->hide();

    if(flag == 1)
    {
        ui->label_4->hide();
    }
    QMovie *mov2 = new QMovie(":/image/1111.gif");      //播放开机动画
    QSize siz1;
    siz1=ui->label_4->size();
    mov2->setScaledSize(siz1);
    ui->label_4->setMovie(mov2);
    mov2->start();

    QTimer *t = new QTimer(this);                       //定时器功能，定义开机动画的时间
    connect(t,SIGNAL(timeout()),this,SLOT(closewindow()));
    t->start(7000);
    flag=1;

}

mainwindow::~mainwindow()
{
    delete ui;
}

void mainwindow::on_begin_clicked()     //点击后显示选关的界面
{
    level lev;
    this->hide();   //当前窗口隐藏
    lev.show();     //显示选关的界面
    lev.exec();     //停留在选关的界面
    /*if(lev.op==1)
       this->show();*/
}

void mainwindow::on_pushButton_clicked()        //将其他的不需要的部件隐藏起来，显示规则页面
{
    ui->label_2->show();
    ui->label_3->hide();
    ui->pushButton_2->show();
    ui->label->hide();
    ui->begin->hide();
    ui->end->hide();
    ui->pushButton->hide();
}

void mainwindow::on_pushButton_2_clicked()  //在进入规则页面后，显示此按钮，点击后回到主界面
{
    ui->label->show();
    ui->label_3->show();
    ui->begin->show();
    ui->end->show();
    ui->pushButton->show();
    ui->label_2->hide();
    ui->pushButton_2->hide();
}
void mainwindow::closewindow()      //退出程序
{
    ui->label_4->close();
}


